<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Win32::Registry - win32: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="Registry/Constants.html">Win32::Registry::Constants</a>
    <li><span class="include">Enumerable</span>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-create">::create</a>
    <li ><a href="#method-c-expand_environ">::expand_environ</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-open">::open</a>
    <li ><a href="#method-c-time2wtime">::time2wtime</a>
    <li ><a href="#method-c-type2name">::type2name</a>
    <li ><a href="#method-c-wtime2time">::wtime2time</a>
    <li ><a href="#method-i-5B-5D">#[]</a>
    <li ><a href="#method-i-5B-5D-3D">#[]=</a>
    <li ><a href="#method-i-_dump">#_dump</a>
    <li ><a href="#method-i-close">#close</a>
    <li ><a href="#method-i-create">#create</a>
    <li ><a href="#method-i-created-3F">#created?</a>
    <li ><a href="#method-i-delete">#delete</a>
    <li ><a href="#method-i-delete_key">#delete_key</a>
    <li ><a href="#method-i-delete_value">#delete_value</a>
    <li ><a href="#method-i-each">#each</a>
    <li ><a href="#method-i-each_key">#each_key</a>
    <li ><a href="#method-i-each_value">#each_value</a>
    <li ><a href="#method-i-flush">#flush</a>
    <li ><a href="#method-i-info">#info</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-keys">#keys</a>
    <li ><a href="#method-i-name">#name</a>
    <li ><a href="#method-i-open">#open</a>
    <li ><a href="#method-i-open-3F">#open?</a>
    <li ><a href="#method-i-read">#read</a>
    <li ><a href="#method-i-read_bin">#read_bin</a>
    <li ><a href="#method-i-read_i">#read_i</a>
    <li ><a href="#method-i-read_s">#read_s</a>
    <li ><a href="#method-i-read_s_expand">#read_s_expand</a>
    <li ><a href="#method-i-values">#values</a>
    <li ><a href="#method-i-write">#write</a>
    <li ><a href="#method-i-write_bin">#write_bin</a>
    <li ><a href="#method-i-write_i">#write_i</a>
    <li ><a href="#method-i-write_s">#write_s</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Win32::Registry">
    <h1 id="class-Win32::Registry" class="class">
      class Win32::Registry
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-disposition" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">disposition</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Disposition value (REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY).</p>
              </div>
            </div>
          <div id="attribute-i-hkey" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">hkey</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns key handle value.</p>
              </div>
            </div>
          <div id="attribute-i-keyname" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">keyname</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Same as subkey value of <a href="Registry.html#method-c-open"><code>Registry.open</code></a> or <a href="Registry.html#method-c-create"><code>Registry.create</code></a> method.</p>
              </div>
            </div>
          <div id="attribute-i-parent" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">parent</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p><a href="Registry.html"><code>Win32::Registry</code></a> object of parent key, or nil if predefeined key.</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-create" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create</span><span
                                class="method-args">(hkey, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |obj| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>— <a href="Registry.html#method-c-create"><code>Registry.create</code></a>(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)</p>

<p>— <a href="Registry.html#method-c-create"><code>Registry.create</code></a>(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| … }</p>

<p>Create or open the registry key subkey under key. You can use predefined key HKEY_* (see <a href="Registry/Constants.html"><code>Constants</code></a>)</p>

<p>If subkey is already exists, key is opened and <a href="Registry.html#method-i-created-3F"><code>Registry#created?</code></a> method will return false.</p>

<p>If block is given, the key is closed automatically.</p>

                              <div class="method-source-code" id="create-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 457</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">create</span>(<span class="ruby-identifier">hkey</span>, <span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">desired</span> = <span class="ruby-constant">KEY_ALL_ACCESS</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-constant">REG_OPTION_RESERVED</span>)
  <span class="ruby-identifier">newkey</span>, <span class="ruby-identifier">disp</span> = <span class="ruby-constant">API</span>.<span class="ruby-constant">CreateKey</span>(<span class="ruby-identifier">hkey</span>.<span class="ruby-identifier">hkey</span>, <span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-identifier">desired</span>)
  <span class="ruby-identifier">obj</span> = <span class="ruby-identifier">new</span>(<span class="ruby-identifier">newkey</span>, <span class="ruby-identifier">hkey</span>, <span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">disp</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-keyword">yield</span> <span class="ruby-identifier">obj</span>
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">close</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">obj</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-expand_environ" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">expand_environ</span><span
                                class="method-args">(str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Replace %w+% into the environment value of what is contained between the %‘s This method is used for REG_EXPAND_SZ.</p>

<p>For detail, see <a href="http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp">expandEnvironmentStrings</a> Win32 API.</p>

                              <div class="method-source-code" id="expand_environ-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 373</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">expand_environ</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">compile</span>(<span class="ruby-string">&quot;%([^%]+)%&quot;</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-identifier">str</span>.<span class="ruby-identifier">encoding</span>))) {
    <span class="ruby-identifier">v</span> = <span class="ruby-node">$1</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">LOCALE</span>)
    (<span class="ruby-identifier">e</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-identifier">v</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">ENV</span>[<span class="ruby-identifier">v</span>.<span class="ruby-identifier">upcase</span>]; <span class="ruby-identifier">e</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-identifier">str</span>.<span class="ruby-identifier">encoding</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">e</span>) <span class="ruby-operator">||</span>
    <span class="ruby-node">$&amp;</span>
  }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(hkey, parent, keyname, disposition)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>initialize</p>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 479</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">hkey</span>, <span class="ruby-identifier">parent</span>, <span class="ruby-identifier">keyname</span>, <span class="ruby-identifier">disposition</span>)
  <span class="ruby-ivar">@hkey</span> = <span class="ruby-identifier">hkey</span>
  <span class="ruby-ivar">@parent</span> = <span class="ruby-identifier">parent</span>
  <span class="ruby-ivar">@keyname</span> = <span class="ruby-identifier">keyname</span>
  <span class="ruby-ivar">@disposition</span> = <span class="ruby-identifier">disposition</span>
  <span class="ruby-ivar">@hkeyfinal</span> = [ <span class="ruby-identifier">hkey</span> ]
  <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span> <span class="ruby-keyword">self</span>, <span class="ruby-identifier">@@final</span>.<span class="ruby-identifier">call</span>(<span class="ruby-ivar">@hkeyfinal</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-open" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">open</span><span
                                class="method-args">(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) { |obj| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>— <a href="Registry.html#method-c-open"><code>Registry.open</code></a>(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)</p>

<p>— <a href="Registry.html#method-c-open"><code>Registry.open</code></a>(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) { |reg| … }</p>

<p>Open the registry key subkey under key. key is <a href="Registry.html"><code>Win32::Registry</code></a> object of parent key. You can use predefined key HKEY_* (see <a href="Registry/Constants.html"><code>Constants</code></a>) desired and opt is access mask and key option. For detail, see the <a href="http://msdn.microsoft.com/library/en-us/sysinfo/base/regopenkeyex.asp">MSDN</a>. If block is given, the key is closed automatically.</p>

                              <div class="method-source-code" id="open-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 429</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">open</span>(<span class="ruby-identifier">hkey</span>, <span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">desired</span> = <span class="ruby-constant">KEY_READ</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-constant">REG_OPTION_RESERVED</span>)
  <span class="ruby-identifier">subkey</span> = <span class="ruby-identifier">subkey</span>.<span class="ruby-identifier">chomp</span>(<span class="ruby-string">&#39;\\&#39;</span>)
  <span class="ruby-identifier">newkey</span> = <span class="ruby-constant">API</span>.<span class="ruby-constant">OpenKey</span>(<span class="ruby-identifier">hkey</span>.<span class="ruby-identifier">hkey</span>, <span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-identifier">desired</span>)
  <span class="ruby-identifier">obj</span> = <span class="ruby-identifier">new</span>(<span class="ruby-identifier">newkey</span>, <span class="ruby-identifier">hkey</span>, <span class="ruby-identifier">subkey</span>, <span class="ruby-constant">REG_OPENED_EXISTING_KEY</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-keyword">yield</span> <span class="ruby-identifier">obj</span>
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">close</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">obj</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-time2wtime" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">time2wtime</span><span
                                class="method-args">(time)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Convert Time object or Integer object into 64-bit FILETIME.</p>

                              <div class="method-source-code" id="time2wtime-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 409</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">time2wtime</span>(<span class="ruby-identifier">time</span>)
  <span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">*</span> <span class="ruby-value">10000000</span> <span class="ruby-operator">+</span> <span class="ruby-value">116444736000000000</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-type2name" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">type2name</span><span
                                class="method-args">(type)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Convert registry type value to readable string.</p>

                              <div class="method-source-code" id="type2name-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 395</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">type2name</span>(<span class="ruby-identifier">type</span>)
  <span class="ruby-identifier">@@type2name</span>[<span class="ruby-identifier">type</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-wtime2time" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">wtime2time</span><span
                                class="method-args">(wtime)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Convert 64-bit FILETIME integer into Time object.</p>

                              <div class="method-source-code" id="wtime2time-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 402</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">wtime2time</span>(<span class="ruby-identifier">wtime</span>)
  <span class="ruby-constant">Time</span>.<span class="ruby-identifier">at</span>((<span class="ruby-identifier">wtime</span> <span class="ruby-operator">-</span> <span class="ruby-value">116444736000000000</span>) <span class="ruby-operator">/</span> <span class="ruby-value">10000000</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-5B-5D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">[]</span><span
                                class="method-args">(name, *rtype)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Read a registry value named name and return its value data. The class of the value is the same as the <a href="Registry.html#method-i-read"><code>read</code></a> method returns.</p>

<p>If the value type is REG_EXPAND_SZ, returns value data whose environment variables are replaced. If the value type is neither REG_SZ, REG_MULTI_SZ, REG_DWORD, REG_DWORD_BIG_ENDIAN, nor REG_QWORD, TypeError is raised.</p>

<p>The meaning of rtype is the same as for the <a href="Registry.html#method-i-read"><code>read</code></a> method.</p>

                              <div class="method-source-code" id="5B-5D-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 679</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">rtype</span>)
  <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span> = <span class="ruby-identifier">read</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">rtype</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_SZ</span>, <span class="ruby-constant">REG_DWORD</span>, <span class="ruby-constant">REG_QWORD</span>, <span class="ruby-constant">REG_MULTI_SZ</span>
    <span class="ruby-identifier">data</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_EXPAND_SZ</span>
    <span class="ruby-constant">Registry</span>.<span class="ruby-identifier">expand_environ</span>(<span class="ruby-identifier">data</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;Type #{Registry.type2name(type)} is not supported.&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-5B-5D-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">[]=</span><span
                                class="method-args">(name, rtype, value = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Write value to a registry value named name.</p>

<p>If wtype is specified, the value type is it. Otherwise, the value type is depend on class of value: :Integer</p>

<pre class="ruby"><span class="ruby-constant">REG_DWORD</span>
</pre>

<p>:String</p>

<pre class="ruby"><span class="ruby-constant">REG_SZ</span>
</pre>

<p>:Array</p>

<pre class="ruby"><span class="ruby-constant">REG_MULTI_SZ</span>
</pre>

                              <div class="method-source-code" id="5B-5D-3D-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 777</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]=</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">rtype</span>, <span class="ruby-identifier">value</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>
    <span class="ruby-identifier">write</span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">rtype</span>, <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">value</span> = <span class="ruby-identifier">rtype</span>
    <span class="ruby-keyword">when</span> <span class="ruby-constant">Integer</span>
      <span class="ruby-identifier">write</span> <span class="ruby-identifier">name</span>, <span class="ruby-constant">REG_DWORD</span>, <span class="ruby-identifier">value</span>
    <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
      <span class="ruby-identifier">write</span> <span class="ruby-identifier">name</span>, <span class="ruby-constant">REG_SZ</span>, <span class="ruby-identifier">value</span>
    <span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span>
      <span class="ruby-identifier">write</span> <span class="ruby-identifier">name</span>, <span class="ruby-constant">REG_MULTI_SZ</span>, <span class="ruby-identifier">value</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;Unexpected type #{value.class}&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">value</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-_dump" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">_dump</span><span
                                class="method-args">(depth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>marshalling is not allowed</p>

                              <div class="method-source-code" id="_dump-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 534</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">_dump</span>(<span class="ruby-identifier">depth</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-string">&quot;can&#39;t dump Win32::Registry&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-close" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">close</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Close key.</p>

<p>After close, most method raise an error.</p>

                              <div class="method-source-code" id="close-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 557</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">close</span>
  <span class="ruby-constant">API</span>.<span class="ruby-constant">CloseKey</span>(<span class="ruby-ivar">@hkey</span>)
  <span class="ruby-ivar">@hkey</span> = <span class="ruby-ivar">@parent</span> = <span class="ruby-ivar">@keyname</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@hkeyfinal</span>[<span class="ruby-value">0</span>] = <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-create" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create</span><span
                                class="method-args">(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &amp;blk)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Same as <a href="Registry.html#method-c-create"><code>Win32::Registry.create</code></a> (self, subkey, desired, opt)</p>

                              <div class="method-source-code" id="create-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 548</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create</span>(<span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">desired</span> = <span class="ruby-constant">KEY_ALL_ACCESS</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-constant">REG_OPTION_RESERVED</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">create</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">desired</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-created-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">created?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns if key is created ((<strong>newly</strong>)). (see <a href="Registry.html#method-c-create"><code>Registry.create</code></a>) – basically you call create then when you call created? on the instance returned it will tell if it was successful or not</p>

                              <div class="method-source-code" id="created-3F-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 504</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">created?</span>
  <span class="ruby-ivar">@disposition</span> <span class="ruby-operator">==</span> <span class="ruby-constant">REG_CREATED_NEW_KEY</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-delete" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">delete</span><span
                                class="method-args">(name)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Registry.html#method-i-delete_value">delete_value</a>
                            </div>
                          </div>

                  <div id="method-i-delete_key" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">delete_key</span><span
                                class="method-args">(name, recursive = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Delete a subkey named name and all its values.</p>

<p>If recursive is false, the subkey must not have subkeys. Otherwise, this method deletes all subkeys and values recursively.</p>

                              <div class="method-source-code" id="delete_key-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 840</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_key</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">recursive</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">recursive</span>
    <span class="ruby-identifier">open</span>(<span class="ruby-identifier">name</span>, <span class="ruby-constant">KEY_ALL_ACCESS</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">reg</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">reg</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">begin</span>
          <span class="ruby-identifier">reg</span>.<span class="ruby-identifier">delete_key</span>(<span class="ruby-identifier">key</span>, <span class="ruby-keyword">true</span>)
        <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Error</span>
          <span class="ruby-comment">#</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-constant">API</span>.<span class="ruby-constant">DeleteKey</span>(<span class="ruby-ivar">@hkey</span>, <span class="ruby-identifier">name</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-constant">API</span>.<span class="ruby-constant">EnumKey</span> <span class="ruby-ivar">@hkey</span>, <span class="ruby-value">0</span>
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Error</span>
      <span class="ruby-keyword">return</span> <span class="ruby-constant">API</span>.<span class="ruby-constant">DeleteKey</span>(<span class="ruby-ivar">@hkey</span>, <span class="ruby-identifier">name</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">5</span>) <span class="ruby-comment">## ERROR_ACCESS_DENIED</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-delete_value" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">delete_value</span><span
                                class="method-args">(name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Delete a registry value named name. We can not delete the ‘default’ value.</p>

                              <div class="method-source-code" id="delete_value-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 829</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_value</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-constant">API</span>.<span class="ruby-constant">DeleteValue</span>(<span class="ruby-ivar">@hkey</span>, <span class="ruby-identifier">name</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Registry.html#method-i-delete">delete</a>
                            </div>

                          </div>

                  <div id="method-i-each" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">each</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Registry.html#method-i-each_value">each_value</a>
                            </div>
                          </div>

                  <div id="method-i-each_key" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each_key</span><span
                                class="method-args">() { |subkey, wtime| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Enumerate subkeys.</p>

<p>subkey is String which contains name of subkey. wtime is last write time as FILETIME (64-bit integer). (see <a href="Registry.html#method-c-wtime2time"><code>Registry.wtime2time</code></a>)</p>

                              <div class="method-source-code" id="each_key-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 603</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_key</span>
  <span class="ruby-identifier">index</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">while</span> <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">wtime</span> = <span class="ruby-constant">API</span>.<span class="ruby-constant">EnumKey</span>(<span class="ruby-ivar">@hkey</span>, <span class="ruby-identifier">index</span>)
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Error</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">subkey</span> = <span class="ruby-identifier">export_string</span>(<span class="ruby-identifier">subkey</span>)
    <span class="ruby-keyword">yield</span> <span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">wtime</span>
    <span class="ruby-identifier">index</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">index</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each_value" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each_value</span><span
                                class="method-args">() { |subkey, type, data| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Enumerate values.</p>

                              <div class="method-source-code" id="each_value-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 566</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_value</span>
  <span class="ruby-identifier">index</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">while</span> <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">subkey</span> = <span class="ruby-constant">API</span>.<span class="ruby-constant">EnumValue</span>(<span class="ruby-ivar">@hkey</span>, <span class="ruby-identifier">index</span>)
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Error</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">subkey</span> = <span class="ruby-identifier">export_string</span>(<span class="ruby-identifier">subkey</span>)
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span> = <span class="ruby-identifier">read</span>(<span class="ruby-identifier">subkey</span>)
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Error</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">yield</span> <span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">index</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">index</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Registry.html#method-i-each">each</a>
                            </div>

                          </div>

                  <div id="method-i-flush" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">flush</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Write all the attributes into the registry file.</p>

                              <div class="method-source-code" id="flush-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 865</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">flush</span>
  <span class="ruby-constant">API</span>.<span class="ruby-constant">FlushKey</span> <span class="ruby-ivar">@hkey</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-info" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">info</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns key information as Array of: :num_keys</p>

<pre>The number of subkeys.</pre>

<p>:max_key_length</p>

<pre>Maximum length of name of subkeys.</pre>

<p>:num_values</p>

<pre>The number of values.</pre>

<p>:max_value_name_length</p>

<pre>Maximum length of name of values.</pre>

<p>:max_value_length</p>

<pre>Maximum length of value of values.</pre>

<p>:descriptor_length</p>

<pre>Length of security descriptor.</pre>

<p>:wtime</p>

<pre>Last write time as FILETIME(64-bit integer)</pre>

<p>For detail, see <a href="http://msdn.microsoft.com/library/en-us/sysinfo/base/regqueryinfokey.asp">RegQueryInfoKey</a> <a href="../Win32.html"><code>Win32</code></a> <a href="Registry/API.html"><code>API</code></a>.</p>

                              <div class="method-source-code" id="info-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 888</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">info</span>
  <span class="ruby-constant">API</span>.<span class="ruby-constant">QueryInfoKey</span>(<span class="ruby-ivar">@hkey</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inspect</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="inspect-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 527</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inspect</span>
  <span class="ruby-node">&quot;\#&lt;Win32::Registry key=#{name.inspect}&gt;&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-keys" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">keys</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>return keys as an array</p>

                              <div class="method-source-code" id="keys-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 621</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">keys</span>
  <span class="ruby-identifier">keys_ary</span> = []
  <span class="ruby-identifier">each_key</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>,<span class="ruby-operator">|</span> <span class="ruby-identifier">keys_ary</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">key</span> }
  <span class="ruby-identifier">keys_ary</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-name" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">name</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Full path of key such as ‘HKEY_CURRENT_USERSOFTWAREfoobar’.</p>

                              <div class="method-source-code" id="name-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 518</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">name</span>
  <span class="ruby-identifier">parent</span> = <span class="ruby-keyword">self</span>
  <span class="ruby-identifier">name</span> = <span class="ruby-ivar">@keyname</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">parent</span> = <span class="ruby-identifier">parent</span>.<span class="ruby-identifier">parent</span>
    <span class="ruby-identifier">name</span> = <span class="ruby-identifier">parent</span>.<span class="ruby-identifier">keyname</span> <span class="ruby-operator">+</span> <span class="ruby-string">&#39;\\&#39;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">name</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">name</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-open" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">open</span><span
                                class="method-args">(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &amp;blk)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Same as <a href="Registry.html#method-c-open"><code>Win32::Registry.open</code></a> (self, subkey, desired, opt)</p>

                              <div class="method-source-code" id="open-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 541</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">open</span>(<span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">desired</span> = <span class="ruby-constant">KEY_READ</span>, <span class="ruby-identifier">opt</span> = <span class="ruby-constant">REG_OPTION_RESERVED</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">open</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">subkey</span>, <span class="ruby-identifier">desired</span>, <span class="ruby-identifier">opt</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-open-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">open?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns if key is not closed.</p>

                              <div class="method-source-code" id="open-3F-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 511</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">open?</span>
  <span class="ruby-operator">!</span><span class="ruby-ivar">@hkey</span>.<span class="ruby-identifier">nil?</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read</span><span
                                class="method-args">(name, *rtype)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Read a registry value named name and return array of [ type, data ]. When name is nil, the ‘default’ value is read. type is value type. (see <a href="Registry/Constants.html"><code>Win32::Registry::Constants</code></a> module) data is value data, its class is: :REG_SZ, REG_EXPAND_SZ</p>

<pre class="ruby"><span class="ruby-constant">String</span>
</pre>

<p>:REG_MULTI_SZ</p>

<pre class="ruby"><span class="ruby-constant">Array</span> <span class="ruby-identifier">of</span> <span class="ruby-constant">String</span>
</pre>

<p>:REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD</p>

<pre class="ruby"><span class="ruby-constant">Integer</span>
</pre>

<p>:REG_BINARY, REG_NONE</p>

<pre class="ruby"><span class="ruby-constant">String</span> (<span class="ruby-identifier">contains</span> <span class="ruby-identifier">binary</span> <span class="ruby-identifier">data</span>)
</pre>

<p>When rtype is specified, the value type must be included by rtype array, or TypeError is raised.</p>

                              <div class="method-source-code" id="read-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 643</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">rtype</span>)
  <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span> = <span class="ruby-constant">API</span>.<span class="ruby-constant">QueryValue</span>(<span class="ruby-ivar">@hkey</span>, <span class="ruby-identifier">name</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">rtype</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">rtype</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">type</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;Type mismatch (expect [#{
      rtype.map{|t|Registry.type2name(t)}.join(&#39;, &#39;)}] but #{
      Registry.type2name(type)} present)&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_SZ</span>, <span class="ruby-constant">REG_EXPAND_SZ</span>
    [ <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-identifier">name</span>.<span class="ruby-identifier">encoding</span>, <span class="ruby-constant">WCHAR</span>).<span class="ruby-identifier">chop</span> ]
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_MULTI_SZ</span>
    [ <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-identifier">name</span>.<span class="ruby-identifier">encoding</span>, <span class="ruby-constant">WCHAR</span>).<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\0/</span>) ]
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_BINARY</span>, <span class="ruby-constant">REG_NONE</span>
    [ <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span> ]
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_DWORD</span>
    [ <span class="ruby-identifier">type</span>, <span class="ruby-constant">API</span>.<span class="ruby-identifier">unpackdw</span>(<span class="ruby-identifier">data</span>) ]
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_DWORD_BIG_ENDIAN</span>
    [ <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-string">&#39;N&#39;</span>)[<span class="ruby-value">0</span>] ]
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_QWORD</span>
    [ <span class="ruby-identifier">type</span>, <span class="ruby-constant">API</span>.<span class="ruby-identifier">unpackqw</span>(<span class="ruby-identifier">data</span>) ]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;Type #{Registry.type2name(type)} is not supported.&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_bin" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_bin</span><span
                                class="method-args">(name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Read a REG_SZ(<a href="Registry.html#method-i-read_s"><code>read_s</code></a>), REG_DWORD(<a href="Registry.html#method-i-read_i"><code>read_i</code></a>), or REG_BINARY(<a href="Registry.html#method-i-read_bin"><code>read_bin</code></a>) registry value named name.</p>

<p>If the values type does not match, TypeError is raised.</p>

                              <div class="method-source-code" id="read_bin-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 730</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_bin</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">read</span>(<span class="ruby-identifier">name</span>, <span class="ruby-constant">REG_BINARY</span>)[<span class="ruby-value">1</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_i" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_i</span><span
                                class="method-args">(name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Read a REG_SZ(<a href="Registry.html#method-i-read_s"><code>read_s</code></a>), REG_DWORD(<a href="Registry.html#method-i-read_i"><code>read_i</code></a>), or REG_BINARY(<a href="Registry.html#method-i-read_bin"><code>read_bin</code></a>) registry value named name.</p>

<p>If the values type does not match, TypeError is raised.</p>

                              <div class="method-source-code" id="read_i-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 720</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_i</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">read</span>(<span class="ruby-identifier">name</span>, <span class="ruby-constant">REG_DWORD</span>, <span class="ruby-constant">REG_DWORD_BIG_ENDIAN</span>, <span class="ruby-constant">REG_QWORD</span>)[<span class="ruby-value">1</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_s" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_s</span><span
                                class="method-args">(name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Read a REG_SZ(<a href="Registry.html#method-i-read_s"><code>read_s</code></a>), REG_DWORD(<a href="Registry.html#method-i-read_i"><code>read_i</code></a>), or REG_BINARY(<a href="Registry.html#method-i-read_bin"><code>read_bin</code></a>) registry value named name.</p>

<p>If the values type does not match, TypeError is raised.</p>

                              <div class="method-source-code" id="read_s-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 695</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_s</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">read</span>(<span class="ruby-identifier">name</span>, <span class="ruby-constant">REG_SZ</span>)[<span class="ruby-value">1</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_s_expand" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_s_expand</span><span
                                class="method-args">(name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Read a REG_SZ or REG_EXPAND_SZ registry value named name.</p>

<p>If the value type is REG_EXPAND_SZ, environment variables are replaced. Unless the value type is REG_SZ or REG_EXPAND_SZ, TypeError is raised.</p>

                              <div class="method-source-code" id="read_s_expand-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 705</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_s_expand</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span> = <span class="ruby-identifier">read</span>(<span class="ruby-identifier">name</span>, <span class="ruby-constant">REG_SZ</span>, <span class="ruby-constant">REG_EXPAND_SZ</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-constant">REG_EXPAND_SZ</span>
    <span class="ruby-constant">Registry</span>.<span class="ruby-identifier">expand_environ</span>(<span class="ruby-identifier">data</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">data</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-values" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">values</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>return values as an array</p>

                              <div class="method-source-code" id="values-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 590</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">values</span>
  <span class="ruby-identifier">vals_ary</span> = []
  <span class="ruby-identifier">each_value</span> { <span class="ruby-operator">|</span><span class="ruby-operator">*</span>, <span class="ruby-identifier">val</span><span class="ruby-operator">|</span> <span class="ruby-identifier">vals_ary</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">val</span> }
  <span class="ruby-identifier">vals_ary</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write</span><span
                                class="method-args">(name, type, data)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Write data to a registry value named name. When name is nil, write to the ‘default’ value.</p>

<p>type is type value. (see <a href="Registry/Constants.html"><code>Registry::Constants</code></a> module) Class of data must be same as which <a href="Registry.html#method-i-read"><code>read</code></a> method returns.</p>

                              <div class="method-source-code" id="write-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 742</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>)
  <span class="ruby-identifier">termsize</span> = <span class="ruby-value">0</span>
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_SZ</span>, <span class="ruby-constant">REG_EXPAND_SZ</span>
    <span class="ruby-identifier">data</span> = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">WCHAR</span>)
    <span class="ruby-identifier">termsize</span> = <span class="ruby-constant">WCHAR_SIZE</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_MULTI_SZ</span>
    <span class="ruby-identifier">data</span> = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">WCHAR</span>)}.<span class="ruby-identifier">join</span>(<span class="ruby-constant">WCHAR_NUL</span>) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">WCHAR_NUL</span>
    <span class="ruby-identifier">termsize</span> = <span class="ruby-constant">WCHAR_SIZE</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_BINARY</span>, <span class="ruby-constant">REG_NONE</span>
    <span class="ruby-identifier">data</span> = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_s</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_DWORD</span>
    <span class="ruby-identifier">data</span> = <span class="ruby-constant">API</span>.<span class="ruby-identifier">packdw</span>(<span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_i</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_DWORD_BIG_ENDIAN</span>
    <span class="ruby-identifier">data</span> = [<span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_i</span>].<span class="ruby-identifier">pack</span>(<span class="ruby-string">&#39;N&#39;</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">REG_QWORD</span>
    <span class="ruby-identifier">data</span> = <span class="ruby-constant">API</span>.<span class="ruby-identifier">packqw</span>(<span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_i</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;Unsupported type #{Registry.type2name(type)}&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-constant">API</span>.<span class="ruby-constant">SetValue</span>(<span class="ruby-ivar">@hkey</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">termsize</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_bin" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_bin</span><span
                                class="method-args">(name, value)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Write value to a registry value named name.</p>

<p>The value type is REG_SZ(<a href="Registry.html#method-i-write_s"><code>write_s</code></a>), REG_DWORD(<a href="Registry.html#method-i-write_i"><code>write_i</code></a>), or REG_BINARY(<a href="Registry.html#method-i-write_bin"><code>write_bin</code></a>).</p>

                              <div class="method-source-code" id="write_bin-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 821</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_bin</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
  <span class="ruby-identifier">write</span> <span class="ruby-identifier">name</span>, <span class="ruby-constant">REG_BINARY</span>, <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_i" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_i</span><span
                                class="method-args">(name, value)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Write value to a registry value named name.</p>

<p>The value type is REG_SZ(<a href="Registry.html#method-i-write_s"><code>write_s</code></a>), REG_DWORD(<a href="Registry.html#method-i-write_i"><code>write_i</code></a>), or REG_BINARY(<a href="Registry.html#method-i-write_bin"><code>write_bin</code></a>).</p>

                              <div class="method-source-code" id="write_i-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 811</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_i</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
  <span class="ruby-identifier">write</span> <span class="ruby-identifier">name</span>, <span class="ruby-constant">REG_DWORD</span>, <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_i</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_s" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_s</span><span
                                class="method-args">(name, value)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Write value to a registry value named name.</p>

<p>The value type is REG_SZ(<a href="Registry.html#method-i-write_s"><code>write_s</code></a>), REG_DWORD(<a href="Registry.html#method-i-write_i"><code>write_i</code></a>), or REG_BINARY(<a href="Registry.html#method-i-write_bin"><code>write_bin</code></a>).</p>

                              <div class="method-source-code" id="write_s-source">
            <pre><span class="ruby-comment"># File win32/lib/win32/registry.rb, line 801</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_s</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
  <span class="ruby-identifier">write</span> <span class="ruby-identifier">name</span>, <span class="ruby-constant">REG_SZ</span>, <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

